﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;

namespace Business.AID.Extensions
{
    public static class MyExtensions
    {
        public static string RemoveAccents(this String str)
        {
            string comAcentos = "ÄÅÁÂÀÃäáâàãÉÊËÈéêëèÍÎÏÌíîïìÖÓÔÒÕöóôòõÜÚÛüúûùÇç";
            string semAcentos = "AAAAAAaaaaaEEEEeeeeIIIIiiiiOOOOOoooooUUUuuuuCc";

            for (int i = 0; i < comAcentos.Length; i++)
            {
                str = str.Replace(comAcentos[i].ToString(), semAcentos[i].ToString());
            }
            return str;
        }

        public static bool InGroup(this SPUser user, SPGroup group)
        {
            return user.Groups.Cast<SPGroup>().Any(p => p.ID == group.ID);
        }

    }
}
